
package com.taobao.taobaowidget.tabbar.adapter;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.taobao.taobaowidget.popupspinner.BackgroundView;

public class TabBarImageAdapter extends BaseAdapter {

    private Context mContext;

    private List<Drawable> mListData;

    public TabBarImageAdapter(Context context, List<Drawable> data) {
        this.mContext = context;
        this.mListData = data;
    }

    public int getCount() {
        // TODO Auto-generated method stub
        return mListData.size();
    }

    public Object getItem(int pos) {
        // TODO Auto-generated method stub
        return mListData.get(pos);
    }

    public long getItemId(int pos) {
        // TODO Auto-generated method stub
        return pos;
    }

    public View getView(int pos, View contentView, ViewGroup arg2) {
        // TODO Auto-generated method stub

        if (contentView == null) {
            contentView = new ImageView(mContext);
        }

        ((ImageView)contentView).setImageDrawable(mListData.get(pos));
        ((ImageView)contentView).setLayoutParams(new LinearLayout.LayoutParams(100, 100));
        if (pos % 2 == 0) {
            contentView
                    .setBackgroundDrawable(BackgroundView.getDrawable(Color.WHITE, Color.YELLOW));
        } else {
            contentView
                    .setBackgroundDrawable(BackgroundView.getDrawable(Color.WHITE, Color.YELLOW));
        }
        return contentView;
    }

}
